Socket
Socket
Sign inDemoInstall

bs58check

Package Overview
Dependencies
13
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    bs58check

A straightforward implementation of base58-check encoding


Version published
Weekly downloads
797K
decreased by-19.45%
Maintainers
1
Install size
271 kB
Created
Weekly downloads
 

Package description

What is bs58check?

The bs58check npm package is used for encoding and decoding data in Base58Check format. This format is commonly used in cryptocurrencies, such as Bitcoin, for encoding addresses and other data. The package ensures that the data is encoded in a way that includes a checksum to detect errors.

What are bs58check's main functionalities?

Encoding

This feature allows you to encode a buffer of data into a Base58Check encoded string. The encoded string includes a checksum to help detect errors.

const bs58check = require('bs58check');
const data = Buffer.from('Hello, world!');
const encoded = bs58check.encode(data);
console.log(encoded); // Outputs the Base58Check encoded string

Decoding

This feature allows you to decode a Base58Check encoded string back into its original buffer of data. The checksum is verified during the decoding process to ensure data integrity.

const bs58check = require('bs58check');
const encoded = '3vQB7B6MrGQZaxCuFg4oh';
const decoded = bs58check.decode(encoded);
console.log(decoded.toString()); // Outputs the original data

Encoding with Error Handling

This feature demonstrates how to handle errors during the encoding process. If the encoding fails for any reason, an error will be caught and logged.

const bs58check = require('bs58check');
try {
  const data = Buffer.from('Hello, world!');
  const encoded = bs58check.encode(data);
  console.log(encoded); // Outputs the Base58Check encoded string
} catch (error) {
  console.error('Encoding failed:', error);
}

Decoding with Error Handling

This feature demonstrates how to handle errors during the decoding process. If the decoding fails due to an invalid checksum or other issues, an error will be caught and logged.

const bs58check = require('bs58check');
try {
  const encoded = '3vQB7B6MrGQZaxCuFg4oh';
  const decoded = bs58check.decode(encoded);
  console.log(decoded.toString()); // Outputs the original data
} catch (error) {
  console.error('Decoding failed:', error);
}

Other packages similar to bs58check

Readme

Source

bs58check

NPM Package Build Status Dependency status

js-standard-style

A straight forward implementation of base58check extending upon bs58.

Example

var bs58check = require('bs58check')

var decoded = bs58check.decode('5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr')

console.log(decoded)
// => <Buffer 80 ed db dc 11 68 f1 da ea db d3 e4 4c 1e 3f 8f 5a 28 4c 20 29 f7 8a d2 6a f9 85 83 a4 99 de 5b 19>

console.log(bs58check.encode(decoded))
// => 5Kd3NBUAdUnhyzenEwVLy9pBKxSwXvE9FMPyR4UKZvpe6E3AgLr

LICENSE MIT

Keywords

FAQs

Last updated on 26 Jul 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc